***Table A13



use "$data/allmergeprep50_ready.dta", clear
append using "$data/allmergeprep55.dta"
append using "$data/allmergeprep60.dta" 
append using "$data/allmergeprep61.dta"
append using "$data/allmergeprep66.dta"


drop if prin_acty_occ=="X01"| prin_acty_occ=="X02"| prin_acty_occ=="X09"| prin_acty_occ=="X10"| prin_acty_occ=="X99"| prin_acty_occ=="XXX"|prin_acty_occ=="X00"
drop if subs_acty_occ=="X01"| subs_acty_occ=="X02"| subs_acty_occ=="X09"| subs_acty_occ=="X10"| subs_acty_occ=="X99"| subs_acty_occ=="XXX"
destring subs_acty_occ, replace 

*saveold "NSSdata_unemp_emp_survey", replace
*drop if year==200304 
keep if inrange(age,18,65)

*Treated state - Andhra Pradesh
gen treat = (state == 28)


g post = (year==200405)
replace post =1 if year==200304
replace post =1 if year==200910

g posttreat = post*treat
egen stateyear = group(state year)
gen indcode = int(prin_acty_ind/1000)
replace indcode = int(prin_acty_ind/100) if year==199394
gen threedigitind = int(prin_acty_ind/100)
replace threedigitind = int(prin_acty_ind/10) if year==199394

*Any high education is 1 if technical education or college and above general education is obtained 
gen anyhighedu = 0
replace anyhighedu=1 if genedu_recode==5 | tech_edu!=1 

***Unemployed
gen lfp = inrange(status1,0,89)
gen unemployed = status1 == 81
gen unemployed_cond = unemployed
replace unemployed_cond = . if lfp ==0


***Agricultural worker
gen agworker = indcode<15 
gen agworker_cond = agworker
replace agworker_cond = . if lfp == 0 

gen age2 = age*age

gen married = (marstatus>=2) 
replace married = . if marstatus==.

gen education =0
replace education = 1 if gen_edu==8|gen_edu==7
replace education = 2 if gen_edu>=9

gen techedu_recode =0
replace techedu_recode =1 if  tech_edu!=1

egen Dcode = group(state district)

g fakepost = (year==199900)
g placebo = fakepost*treat

tab year, gen(year)
gen treat9394 = year1 * treat
gen treat9900 = year2 * treat
gen treat0304 = year3 * treat
gen treat0405 = year4 * treat
gen treat0910 = year5 * treat 
gen zero=0

label variable treat9394 "1993-94" 
label variable treat9900 "1999-00"
label variable treat0304 "2003-04"
label variable treat0405 "2004-05"
label variable zero "1999-00"
label variable posttreat "Post X Treat"
label variable placebo "Placebo"

gen occlen = strlen(prin_acty_occ)
gen prin_occ_2digit = prin_acty_occ
replace prin_occ_2digit = substr(prin_acty_occ,1,2) if occlen>2
destring prin_occ_2digit, replace
destring prin_acty_occ, replace


*Set the Fixed Effects, Clusters and Controls
global controls  "age age2 sex i.sgroup married i.gen_lit"
global fe_m "state year state#c.year"
*global fe_m "state year state#c.year"
global cl "state"

 

*--------------------------------
*Regressions
*--------------------------------
est clear 
foreach var of varlist lfp unemployed agworker {
*	local var "casualworker2"
	 qui eststo reg_`var': reghdfe `var' ${controls} posttreat /// 
			 [pw=weight] , cluster($cl) absorb($fe_m)
	    qui estadd local fes "Yes"
    	qui estadd local controls "Yes"
    	qui estadd scalar rsq = e(r2)
    	qui summ `var' if treat == 0 & post == 0 
    	qui estadd scalar mean = r(mean)
    	noi di "Done with `var'"
}


# delimit ;
esttab  reg_* using "${output}/nss/TableA13.tex", replace
keep(posttreat)
cells(b(fmt(%5.3f) star) se(fmt(%5.3f) par))
starlevels(* .10 ** .05 *** .01) 
mgroups("LFP" "Unemployed" "Agri. Worker", pattern(1 1  1)
span prefix(\multicolumn{@span}{c}{) suffix(}) erepeat(\cmidrule(lr){@span})) 
mtitles(, none) mlabels(, none)
stats(mean rsq N, labels("Control, Pre Mean" "R2" "N")
fmt(2 2 0)) collabels(none) label booktabs nonotes
;
#delimit cr 







